<?php
	namespace core;

	class goodcms
	{
		public static $classMap = array();
		public $assign = NULL;
		public $display = NULL;
		public static function run(){
			\core\lib\log::init();
			$route      = new \core\lib\route();
			$ctrlClass  = $route->ctrl;
			$action     = $route->action;
			$ctrlfile   =  APP.'/ctrl/'.$ctrlClass.'Ctrl.php';
			$ctrlClass  = MODULE.'\ctrl\\'.$ctrlClass.'Ctrl' ;
			if (is_file( $ctrlfile)){
				include $ctrlfile;
				//实例化
				$ctrl = new $ctrlClass();
				$ctrl->$action();
			}else{
				throw new \ErrorException('找不到控制器' ,$ctrlClass);
				}

									}

		public static function load($class){
		if (isset($classMap[$class])){
			return true;
		}else {
			$class = str_replace('\\' , '/' , $class);
			$file = GOODCMS.'/'.$class.'.php';
		if (is_file($file)){
			include $file;
			self::$classMap[$class] =  $class;
		}
		else{
			return false;
			}
		}
		}

		public function assign($name ,$file){
		$this->assign[$name] = $file;
		}
		public function dispaly($file){
			$file = APP.'/views/'.$file ;
			if (is_file( $file)){
				extract($this->assign);
				include $file;
			}
		}
	}